﻿using CuaHangLego.DataAccess;
using CuaHangLego.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CuaHangLego.Webform.Controls
{
    public partial class ThemeBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IList<ChuDe> listCD = ChuDeDA.Instance.GetAll();
                var data = listCD.OrderBy(cd => cd.Ten);
                Themes.DataSource = data;
                Themes.DataBind();
            }
        }

        protected void Themes_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                ChuDe d = (ChuDe)e.Item.DataItem;
                HyperLink h = (HyperLink)e.Item.FindControl("themeLink");
                h.NavigateUrl = "~/Default.aspx?ThemeID=" + d.MaSo;
            }
        }
    }
}